/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package quanlinganhang.model;

import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import quanlinganhang.dao.AccountDAO;

/**
 *
 * @author SIPO
 */
public class RemoveAccountModel extends AbstractTableModel{
    
    private String[] columnNames = {"Số tài khoản", "Họ và tên", "Số CMND", "Đã Đóng"};
    private ArrayList data;
    
    public RemoveAccountModel() throws SQLException, ClassNotFoundException{
        this.data = AccountDAO.GetListRemoveAccount();
    }

    @Override
    public int getRowCount() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return data.size();
    }

    @Override
    public int getColumnCount() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return columnNames.length;
    }
    
    @Override
    public String getColumnName(int col){
        return columnNames[col];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        if (!data.isEmpty()) {
            return ((ArrayList) data.get(rowIndex)).get(columnIndex);
        }
        return null;
    }
    
    @Override
    public Class getColumnClass(int c) {
        if (getValueAt(0, c) == null) {
            return String.class;
        }
        return getValueAt(0, c).getClass();
    }

    /*
     * Không cho trực tiếp edit trên table
     */
    @Override
    public boolean isCellEditable(int row, int col) {
        return false;
    }
}
